package com.lovo.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.project.bean.JournalBean;
import com.lovo.project.service.JournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@CrossOrigin
@RequestMapping("/journal")
public class JournalController {

    @Autowired
    JournalService journalService;

    @RequestMapping("/queryJournalList")
    public Page<JournalBean> queryJournalList(Integer pg, Integer pgsize, String startTime,String endTime){
        QueryWrapper queryWrapper=new QueryWrapper();
        if (startTime!=null && startTime!=""){
            queryWrapper.ge("journal_time",startTime);
        }
        if (endTime!=null && endTime!=""){
            queryWrapper.le("journal_time",endTime);
        }
       Page<JournalBean> page=new Page<>(pg,pgsize);
        Page<JournalBean> pageInfo=journalService.selectJournalList(page,queryWrapper);
        return pageInfo;
    }
}
